<?
function ShowListFull()
{
	global $db, $table_edit, $arr, $elements, $db_name;
	
	$sql = "select column_name from information_schema.columns where table_name='".$table_edit."' AND table_schema ='".$db_name."'" ;
	
	$arr = $db->getAll($sql);
	
	$elements = ShowListArr($table_edit);
}
function ShowListID()
{
	global $db, $table_edit, $arr_table, $element, $db_name;
	
	$id = $_COOKIE['ad_id'];
	$sql = "select column_name from information_schema.columns where table_name='".$table_edit."' AND table_schema ='".$db_name."'" ;
	//echo $sql;
	$arr_table = $db->getAll($sql);
	
	$sql = "select * from ".$table_edit." where id=$id";
	
	//
	$element = $db->getRow($sql);
}
function EditFull()
{
	global $db, $table_edit, $arr_table, $element, $db_name;
	
	$sql = "select column_name, data_type from information_schema.columns where table_name='".$table_edit."'  AND table_schema ='".$db_name."'";
	
	$arr_table = $db->getAll($sql);
	
	$element = EditElement($table_edit);
}
function ChangeActive($name)
{
	global $table_edit;
	
	ChangeMethod($table_edit, $name);
	
}
function ChangeShowList($name)
{
	global $table_edit;
	
	ChangeShow($table_edit, $name);
}
function ChangeHideList($name)
{
	global $table_edit;
	
	ChangeHide($table_edit, $name);
}
function Order()
{
	global $table_edit;
	OrderList($table_edit);
}
function TransList()
{
	global $db, $table_edit;
	$id=$_POST["iddel"];
	//print_r($id);
	for($i=0;$i<count($id);$i++){
		transferDataToArticles($id[$i]);
		$sql="update ".$table_edit." set status = 2 where id=".$id[$i];
		$db->query($sql);		
	}
	$msg="Update successfully";		
	$_SESSION['mess'] = $msg;
	$page="admin-pro.html?do=".$table_edit. (isset($_GET['cid'])?'&cid='.$_GET['cid']:'') . (isset($_GET['page'])?'&page='.$_GET['page']:'');
	page_transfer2($page);
}
function DelList()
{
	global $table_edit;
	
	DelListElement($table_edit);
}

function Del()
{
	global $table_edit;
	
	DelElement($table_edit);
}

function PostClean($name)
{
	$value = isset($_POST[$name])?$_POST[$name]:'';
	
	if($value)
		return $value;
	return '';	
}
function GetClean($name)
{
	$value = isset($_GET[$name])?$_GET[$name]:'';
	
	if($value)
		return $value;
	return '';	
}
function ArrPostClean($arr, $name)
{
	$value = isset($_POST[$name])?$_POST[$name]:'';
	
	if($value)
		$arr[$name] = $value;
	return $arr;	
}
function ArrGetClean($arr, $name)
{
	$value = isset($_GET[$name])?$_GET[$name]:'';
	
	if($value)
		$arr[$name] = $value;
	return $arr;	
}
function ArrPostClean2($arr, $name, $name2)
{
	$value = isset($_POST[$name2])?$_POST[$name2]:'';
	
	if($value)
		$arr[$name] = $value;
	return $arr;	
}
function ArrGetClean2($arr, $name, $name2)
{
	$value = isset($_GET[$name2])?$_GET[$name2]:'';
	
	if($value)
		$arr[$name] = $value;
	return $arr;	
}
function ArrPostCleanActive($arr, $name)
{
	$value = isset($_POST[$name])?$_POST[$name]:'';
	
	$value = ($value == 'on')?'1':'0';
	
	$arr[$name] = $value;
		
	return $arr;	
}
function ShowListArr($table_edit)
{
	global $db, $page, $plpage, $set_per_page, $c;
	$set_per_page=20; 
	if(isset($_GET['cid']) && $_GET['cid']!=1 && $_GET['cid']!='')
		$sql="select p.* from ".$table_edit." p where p.cid=".$_GET['cid']." order by p.num asc, p.id desc ";
	else
		$sql="select * from ".$table_edit." order by num asc, id desc ";
	//echo $sql;	
	$c = $db->numRows($db->query($sql));
	$plpage = plpage($sql,$page,$set_per_page);
	$sqlstmt = sqlmod($sql,$page,$set_per_page);	
	return $db->getAll($sqlstmt);	
}
function EditElement($table_edit)
{
	global $db;
	
	if($_GET['act'] == 'edit_full')
	{
		$id=$_GET["id"];
		$sql = "select * from ".$table_edit." where id=$id";
		return $db->getRow($sql);
	}
}
function OrderList($table_edit)
{
	global $db;
	$id=$_POST["id"];	
	$ordering=$_POST["ordering"];		
	for($i=0;$i<count($id);$i++){
		$sql="update ".$table_edit." set num=".$ordering[$i]." where id=".$id[$i];
		$db->query($sql);		
	}
	$msg="Order successfully";		
	$_SESSION['mess'] = $msg;
	$page="admin-pro.html?do=".$table_edit. (isset($_GET['cid'])?'&cid='.$_GET['cid']:'') . (isset($_GET['page'])?'&page='.$_GET['page']:'');
	page_transfer2($page);
}
function ChangeMethod($table_edit, $name)
{
	global $db;
	$id=$_GET["id"];
	$cid = isset($_GET["cid"])?$_GET["cid"]:'';
	
	$active = $_GET['current']==1?0:1;
	$sql="update ".$table_edit." set ".$name."=".$active." where id=$id";
	$db->query($sql);	
	
	$msg="Update successfully";	
		
	if(!empty($_GET['cid']))
		$page="admin-pro.html?do=".$table_edit.(isset($_GET['cid'])?'&cid='.$_GET['cid']:''). "&page=" . ($_GET['page']!=""?$_GET['page']:1);
	else
		$page="admin-pro.html?do=".$table_edit;
	$_SESSION['mess'] = $msg;
	page_transfer2($page);	
}
function ChangeShow($table_edit, $name)
{
	global $db;
	$id=$_POST["iddel"];
	for($i=0;$i<count($id);$i++){
		$sql="update ".$table_edit." set ".$name." = 1 where id=".$id[$i];
		$db->query($sql);		
	}
	$msg="Update successfully";		
	$_SESSION['mess'] = $msg;
	$page="admin-pro.html?do=".$table_edit. (isset($_GET['cid'])?'&cid='.$_GET['cid']:'') . (isset($_GET['page'])?'&page='.$_GET['page']:'');
	page_transfer2($page);
}
function ChangeHide($table_edit, $name)
{
	global $db;
	$id=$_POST["iddel"];
	for($i=0;$i<count($id);$i++){
		$sql="update ".$table_edit." set ".$name." =0 where id=".$id[$i];
		$db->query($sql);		
	}
	$msg="Update successfully";		
	$_SESSION['mess'] = $msg;
	$page="admin-pro.html?do=".$table_edit. (isset($_GET['cid'])?'&cid='.$_GET['cid']:'') . (isset($_GET['page'])?'&page='.$_GET['page']:'');
	page_transfer2($page);
}
function DelListElement($table_edit)
{
	global $db;
	$id=$_POST["iddel"];		
	for($i=0;$i<count($id);$i++){
		$sqlstmt="select img from ".$table_edit." where id=".$id[$i];
		$r = $db->getRow($sqlstmt);
		//if(file_exists($r['img'])) unlink($r['img']);		
				
		$sql="delete from ".$table_edit." where id=".$id[$i];
		$db->query($sql);		
	}
	$msg="Delete successfully";		
	$_SESSION['mess'] = $msg;
	$page="admin-pro.html?do=".$table_edit. (isset($_GET['cid'])?'&cid='.$_GET['cid']:'') . (isset($_GET['page'])?'&page='.$_GET['page']:'');
	page_transfer2($page);
}
function DelElement($table_edit)
{
	global $db;
	$id=$_GET["id"];

	$sqlstmt="select img from ".$table_edit." where id=$id";
	$r = $db->getRow($sqlstmt);
	//if(file_exists($r['img'])) unlink($r['img']);		
	
	$sql="delete from ".$table_edit."  where id=".$id;
	$db->query($sql);	
		
	$msg="Delete successfully";		
	$_SESSION['mess'] = $msg;
	$page="admin-pro.html?do=".$table_edit. (isset($_GET['cid'])?'&cid='.$_GET['cid']:'') . (isset($_GET['page'])?'&page='.$_GET['page']:'');
	page_transfer2($page);
}
function DownloadImage($str)
{
	global $FullUrl, $arrImageHost;
	$arrImageWeb = GetLinkImagesFromWebOther($str);
	//echo 'get link roi';
	//print_r($arrImageWeb);
	$dir = "kam/upload/images/webOthers/";
	$arrImageHost = ChangeImageName($arrImageWeb, $dir);		
	//print_r($arrImageHost);
	
	for($i = 0; $i < count($arrImageWeb); $i++)
	{
		$arrImageWeb[$i] = str_replace("%20"," ", $arrImageWeb[$i]);
		DownloadImageFromWeb($arrImageWeb[$i], $arrImageHost[$i]);	
	}
			
	for($i = 0; $i < count($arrImageHost); $i++)		
	{
		$arrImageHost[$i] = "/".$arrImageHost[$i];	
	}
	//echo 'thay link';
	//print_r($arrImageWeb);
	//print_r($arrImageHost);
	if(count($arrImageWeb) > 0 && count($arrImageHost) > 0)
	{
		//echo 'thay link';
		$str = str_replace($arrImageWeb, $arrImageHost, $str);
	}
	
	return $str;
}
function DownloadImageFromWeb($url, $save)
{
	if($url != "" && strlen($url) > 4)
	{
		$kt_http =  $url[0].$url[1].$url[2].$url[3];
		
		if($kt_http == "http")
		{
			$content = file_get_contents($url);
			
			//print_r($content);
			file_put_contents($save, $content);	
		}
	}
}
function save_image($inPath,$outPath)
{ //Download images from remote server
    $in=    fopen($inPath, "rb");
    $out=   fopen($outPath, "wb");
    while ($chunk = fread($in,8192))
    {
        fwrite($out, $chunk, 8192);
    }
    fclose($in);
    fclose($out);
}

function ChangeImageName($arrImageWeb, $dir)
{		
	
	$index = 0;
	
	for($i = 0; $i < count($arrImageWeb); $i++)	
	{
		$name = GetImageName($arrImageWeb[$i]);
		$rs[$index] = $dir.$name;
		$index++;	
	}
	
	return $rs;
}
function GetImageName($str)
{
	$rs = "";
	$index = 0;
	
	if(strlen($str) > 4)
	{
	
		for($i = strlen($str)-1; $i > 0 ; $i--)
		{
			if($str[$i] != "/")
				$index = $i;		
			else
				break;	
		}	
		
		for($i = $index; $i < strlen($str); $i++)
			$rs .= $str[$i];
				
		$file_img_ext = $rs[strlen($rs) - 3].$rs[strlen($rs) - 2].$rs[strlen($rs) - 1];
		
		//print($file_img_ext);
		if($file_img_ext == 'PNG' || 
			$file_img_ext == 'png' || 
			$file_img_ext == 'JPG' || 
			$file_img_ext == 'jpg' ||
			$file_img_ext == 'JPEG' || 
			$file_img_ext == 'jpeg' || 
			$file_img_ext == 'GIF' || 
			$file_img_ext == 'gif'  
		)
		{
			
		}
		else
			$rs .= ".jpg";	
	}
	
	return $rs;
}
function GetLinkImagesFromWebOther($str)
{
	$split = "<img"; 
	$arr = (explode($split, $str));
	
	//echo 'cat <img ';
	//print_r($arr);
	$index = 0;
	$result = "";
	
	for($i = 0; $i < count($arr); $i++)
	{			
		if($arr[$i] != "" || $arr[$i] != " ")
		{				
			$split2 = 'src="'; 			
			$arr2 = (explode($split2, $arr[$i]));		
			//print_r($arr2);
			if(count($arr2) > 1)
			{
				$rs = $arr2[1];
				$link = "";
				for($j = 0; $j < strlen($rs); $j++)
				{
					if($rs[$j] != "\\" && $rs[$j] != '"')
					{
						//echo $rs[$j];
						$link .= $rs[$j];
					}
					else
						break;
				}
				
				if($link != "" && strlen($link) > 4)//&& $link[0] != 'h' && $link[1] != 't'&& $link[2] != 't'&& $link[3] != 'p')
				{
					$kt_http =  $link[0].$link[1].$link[2].$link[3];
					
					if($kt_http == "http")
					{
						$result[$index] = $link;			
						$index++;
					}
					
				}
	
			}
		}
	}
	
	//echo 'kq sau cat';
	//print_r($result);
	//echo "END";
	return $result;
	
}
function CreateTitleKey($strName)
{
	$strName = strtolower($strName);
	$strName = trim($strName);
	
	$arrCharA = array("à","á","ạ","ả","ã","â","ầ","ấ","ậ","ẩ","ẫ","ă","ằ","ắ","ặ","ẳ","ẵ", "A", "Á", "À", "Ả", "Ã", "Ạ", "Â", "Ấ", "Ầ", "Ẩ", "Ẫ", "Ậ", "Ă", "Ắ", "Ằ", "Ẳ", "Ẳ", "Ẵ", "Ặ");
	$arrCharE = array("è","é","ẹ","ẻ","ẽ","ê","ề","ế","ệ","ể","ễ", "E", "É", "È", "Ẻ", "Ẽ", "Ẹ", "Ê", "Ế", "Ề", "Ể", "Ễ", "Ệ");
	$arrCharI = array("ì","í","ị","ỉ","ĩ", "Í", "Ì", "Ỉ", "Ĩ", "Ị");
	$arrCharO = array("ò","ó","ọ","ỏ","õ","ô","ồ","ố","ộ","ổ","ỗ","ơ","ờ","ớ","ợ","ở","ỡ", "O", "Ó", "Ò", "Ỏ", "Õ", "Ọ","Ơ", "Ớ", "Ờ", "Ở", "Ỡ", "Ợ", "Ô", "Ố", "Ồ", "Ổ", "Ỗ", "Ộ");
	$arrCharU = array("ù","ú","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ", "U", "Ú", "Ù", "Ủ", "Ũ", "Ụ", "Ư", "Ứ", "Ừ","Ử", "Ữ","Ự");
	$arrCharD = array("Đ","đ");
	$arrCharY = array("ý","ỳ","ỷ","ỹ","ỵ", "Y", "Ý", "Ỳ", "Ỷ", "Ỹ", "Ỵ");
	$arrCharDif = array("!","@","%","^","*","(",")","+","=","<",">","?","/","\\",",",".",":",";","'","\"","&","#","[","]","~","$","_", "...", "..");
	
	$strName = str_replace($arrCharA, "a", $strName);
	$strName = str_replace($arrCharE, "e", $strName);
	$strName = str_replace($arrCharI, "i", $strName);
	$strName = str_replace($arrCharO, "o", $strName);
	$strName = str_replace($arrCharU, "u", $strName);
	$strName = str_replace($arrCharD, "d", $strName);
	$strName = str_replace($arrCharY, "y", $strName);
	$strName = str_replace($arrCharDif, "", $strName);
	
	$rs = "";
	for($i = 0 ; $i < strlen($strName); $i++)
	{
		if( $i == 0 )
		{	
			if($strName[$i] != "-")
				$rs .= $strName[$i];	
		}
		else if($i == (strlen($strName) - 1))
		{	
			if($strName[$i] != "-")
				$rs .= $strName[$i];	
		}
		else
			$rs .= $strName[$i];
	}
	//print(strlen($rs));
	return $rs;
	
}
function CreateUniqueKey($strName)
{
	$strName = strtolower($strName);
	$strName = trim($strName);
	
	$arrCharA = array("à","á","ạ","ả","ã","â","ầ","ấ","ậ","ẩ","ẫ","ă","ằ","ắ","ặ","ẳ","ẵ", "A", "Á", "À", "Ả", "Ã", "Ạ", "Â", "Ấ", "Ầ", "Ẩ", "Ẫ", "Ậ", "Ă", "Ắ", "Ằ", "Ẳ", "Ẳ", "Ẵ", "Ặ");
	$arrCharE = array("è","é","ẹ","ẻ","ẽ","ê","ề","ế","ệ","ể","ễ", "E", "É", "È", "Ẻ", "Ẽ", "Ẹ", "Ê", "Ế", "Ề", "Ể", "Ễ", "Ệ");
	$arrCharI = array("ì","í","ị","ỉ","ĩ", "Í", "Ì", "Ỉ", "Ĩ", "Ị");
	$arrCharO = array("ò","ó","ọ","ỏ","õ","ô","ồ","ố","ộ","ổ","ỗ","ơ","ờ","ớ","ợ","ở","ỡ", "O", "Ó", "Ò", "Ỏ", "Õ", "Ọ","Ơ", "Ớ", "Ờ", "Ở", "Ỡ", "Ợ", "Ô", "Ố", "Ồ", "Ổ", "Ỗ", "Ộ");
	$arrCharU = array("ù","ú","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ", "U", "Ú", "Ù", "Ủ", "Ũ", "Ụ", "Ư", "Ứ", "Ừ","Ử", "Ữ","Ự");
	$arrCharD = array("Đ","đ");
	$arrCharY = array("ý","ỳ","ỷ","ỹ","ỵ", "Y", "Ý", "Ỳ", "Ỷ", "Ỹ", "Ỵ");
	$arrCharDif = array("!","@","%","^","*","(",")","+","=","<",">","?","/","\\",",",".",":",";","'","","\"","&","#","[","]","~","$","_"," ", "...", "..", "“", "”");
	//$arrCharSpace = array("   ","  ");
	$arrCharDif2 = array("---", "--");
	$arrCharDif3 = array("--");
	
	$strName = str_replace($arrCharA, "a", $strName);
	$strName = str_replace($arrCharE, "e", $strName);
	$strName = str_replace($arrCharI, "i", $strName);
	$strName = str_replace($arrCharO, "o", $strName);
	$strName = str_replace($arrCharU, "u", $strName);
	$strName = str_replace($arrCharD, "d", $strName);
	$strName = str_replace($arrCharY, "y", $strName);
	$strName = str_replace($arrCharDif, "-", $strName);
	//$strName = str_replace($arrCharSpace, "-", $strName);
	$strName = str_replace($arrCharDif2, "-", $strName);
	$strName = str_replace($arrCharDif3, "-", $strName);	
	
	$rs = "";
	for($i = 0 ; $i < strlen($strName); $i++)
	{
		if( $i == 0 )
		{	
			if($strName[$i] != "-")
				$rs .= $strName[$i];	
		}
		else if($i == (strlen($strName) - 1))
		{	
			if($strName[$i] != "-")
				$rs .= $strName[$i];	
		}
		else
			$rs .= $strName[$i];
	}
	//print(strlen($rs));
	return $rs;
	
}
// CheckUniqueKey in table Articles
function CheckUniqueKey2($unique_key)
{
		global $db, $table_edit, $lg;
		$sql = "SELECT * FROM `articles` where unique_key_vn = '". $unique_key."'";
		
		$arrRS = $db->getRow($sql);
		
		//print_r($db);
		//print $strQ;
		//print_r($arrRS);
		//print ('test');
		//return $arrRS;
		if($arrRS['unique_key_vn'] == $unique_key)
		{			
			//print 'true';
			return 1;	
		}
		
		return 0;
}
function CheckUniqueKeyGET($unique_key)
{
		global $db, $table_edit, $lg;
		$sql = "SELECT * FROM `get_articles` where unique_key_vn = '". $unique_key."'";
		
		$arrRS = $db->getRow($sql);
		
		if($arrRS['unique_key_vn'] == $unique_key)
		{			
			return 1;	
		}
		
		return 0;
}
function CheckLinkGET($link)
{
		global $db, $table_edit, $lg;
		$sql = "SELECT * FROM `get_articles` where link_href = '". $link."'";
		
		$arrRS = $db->getRow($sql);
		
		if($arrRS['link_href'] == $link)
		{			
			return 1;	
		}
		
		return 0;
}
function CheckUniqueKey3($unique_key, $img)
{
		global $db, $table_edit, $lg;
		$sql = "SELECT * FROM `".$table_edit."` where unique_key_vn = '". $unique_key."'";
		
		$arrRS = $db->getRow($sql);
		
		//print_r($db);
		//print $strQ;
		//print_r($arrRS);
		//print ('test');
		//return $arrRS;
		//Check Unique
		if($arrRS['unique_key_vn'] == $unique_key)
		{			
			// Isset IMG
			if($arrRS['img'] == $img)
			{				
				return 2;
			}
			//print 'true';
			return 1;	
		}
		
		return 0;
}
function RemoveCookieLive($name)
{
	unset($_COOKIE[$name]);
	//return setcookie($name, NULL, -1);
} 

function downloadImageFromContent2($strContent)
{
	global $arrIMGMain, $arrIMG;
	$html = str_get_html($strContent);
	$index = 0;;
	
	// Find Src Img
	foreach($html->find('img') as $element)
	{
		// " http://...jpg "
		// "http://...jpg"
		$arrIMGWeb[$index] = trim($element->src);
		$arrImgWebReal[$index] = $element->src;
		
		$index++;
	}	
	
	
	for($i = 0; $i < count($arrIMGWeb); $i++)
	{
		if($arrIMGWeb[$i] != '')
		{
			// Replace %20 -> " "
			$arrIMGWeb[$i] = str_replace("%20"," ", $arrIMGWeb[$i]);
			
			$temp = downloadImageFromLink($arrIMGWeb[$i]);
			$arrIMGHosting[$i] = "/".$temp['link_get'];
		}
	}
			
	if(count($arrIMGHosting) > 0)
	{
		$rs = str_replace($arrImgWebReal, $arrIMGHosting, $strContent);
	}
	
	// Img Main
	if(count($arrIMGHosting)>0)
	{
		if($arrIMGMain == '')
			$arrIMGMain = substr($arrIMGHosting[0],1,strlen($arrIMGHosting[0])-1);
	}
	
	return $rs;
}
function downloadImageFromContent($strContent)
{
	global $arrIMGMain, $arrIMG;
	$html = str_get_html($strContent);
	$index = 0;;
	foreach($html->find('img') as $element)
	{
		$arrIMGWeb[$index] = trim($element->src);
		$arrIMGWeb2[$index] = $element->src;
		//echo $arrIMGWeb[$index].'<br/>';
		$index++;
	}
	$dir = "kam/upload/images/articles/";
	$arrIMGHosting = ChangeImageName($arrIMGWeb, $dir);
	//print_r($arrIMGHosting);
	
	for($i = 0; $i < count($arrIMGWeb); $i++)
	{
		$arrIMGWeb[$i] = str_replace("%20"," ", $arrIMGWeb[$i]);
		//echo 'Hinh can download:'.$arrIMGWeb[$i].' link:'.$arrIMGHosting[$i];
		DownloadImageFromWeb($arrIMGWeb[$i], $arrIMGHosting[$i]);	
	}
			
	for($i = 0; $i < count($arrIMGHosting); $i++)		
	{
		//$arrIMGHosting[$i] = "/".$arrIMGHosting[$i];	
		$arrIMGHosting[$i] = $arrIMGHosting[$i];	
	}
	
	//echo 'thay link';
	//print_r($arrImageWeb);
	//print_r($arrImageHost);
	if(count($arrIMGWeb) > 0 && count($arrIMGHosting) > 0)
	{
		//echo 'thay link';
		for($i = 0; $i < count($arrIMGHosting); $i++)		
		{
			//$arrIMGHosting[$i] = "/".$arrIMGHosting[$i];	
			$arrIMGHosting2[$i] = "/".$arrIMGHosting[$i];	
		}
		$rs = str_replace($arrIMGWeb2, $arrIMGHosting2, $strContent);
	}
	
	if(count($arrIMGHosting)>0)
	{
		$arrIMGMain = $arrIMGHosting[0];
	}
	//print_r($rs);
	return $rs;
}
function checkImageOnServer($link)
{
	// Server
	// http://batdongsantphcm.vn
	if($link != "" && strlen($link) > 4)//&& $link[0] != 'h' && $link[1] != 't'&& $link[2] != 't'&& $link[3] != 'p')
	{
		$kt_http =  $link[0].$link[1].$link[2].$link[3];
		
		if($kt_http == "http")
		{
			return false;
		}
		
		return true;		
	}
	return false;
}

// Return
// arr['link']
// arr['name']
// arr['link_get']
function downloadImageFromLink($link)
{
	$name = GetImageName($link);
	$dir = "kam/upload/images/articles/";
	
	$filename = $dir.$name;
	if(file_exists('./'.$filename))
	{
		$name .= '-2';
	}
	
	DownloadImageFromWeb($link, $filename);
	
	$arr['link'] = $link;
	$arr['name'] = $name;
	$arr['link_get']= $filename;	
	
	return $arr;
}
?>